package cn.mistorange.mapper;


import cn.mistorange.pojo.Bill;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BillMapper {

    // 插入新账单
    @Insert("INSERT INTO bills (user_id, category_id, description, amount, type, created_at) VALUES (#{userId}, #{categoryId}, #{description}, #{amount}, #{type}, #{createdAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addBill(Bill bill);

    // 根据ID查找账单
    Bill findBillById(Integer id);

    // 更新账单信息
    void updateBill(Bill bill);

    // 删除账单
    @Delete("DELETE FROM bills WHERE id = #{id}")
    void deleteBill(Integer id);

    // 获取所有账单
    List<Bill> findAllBills();


}